<#include "license.ftl">
<@license/>
<#assign object = doc.object>
package ${object.@package}.model.fields;

/**
* A list of tall the attributes of ${object.@name} and their corresponding java.sql.Types value.
* To make his enum portable to GWT, the numeric value of Types is used, here is the legend:<br>
* Types.INTEGER      4 <br>
* Types.BIGINT      -5 <br>
* Types.DATE        91 <br>
* Types.BOOLEAN     16 <br>
* Types.CHAR         1 <br>
* Types.LONGVARCHAR -1 <br>
* Types.VARCHAR     12 <br>
* Types.DOUBLE     8 <br>
* @author Redora
* @see java.sql.Types
*/
public enum ${object.@name}Fields {
    id(-5)
    ,creationDate(91)
    ,updateDate(91)
<#list object.formScope?children as att>
    <#if att?node_type == "element" && att?node_name != "object">
        <#if att.description[0]??>
    /** ${att.description} */
        </#if>
    ,${att.@fieldName}<#t>
        <#if att?node_name == "boolean">
        (16)<#t>

        <#elseif att?node_name == "date" || att?node_name == "datetime">
        (91)<#t>

        <#elseif att?node_name == "enum">
        (1)<#t>

        <#elseif att?node_name == "integer">
        (4)<#t>

        <#elseif att?node_name == "long">
        (-5)<#t>

        <#elseif att?node_name == "string">
            <#if att.@maxlength[0]?number &gt; 65000>
        (-1)<#t>

            <#else>
        (12)<#t>

            </#if>
        <#elseif att?node_name == "html">
        (-1)<#t>

        <#elseif att?node_name == "double">
        (8)<#t>

        <#else>
        ERROR, undefined node ${att?node_name}
        </#if>
	</#if>
</#list>;<#t>

    public int sqlType;
    private ${object.@name}Fields(int sqlType) {
        this.sqlType = sqlType;
    }
  
    /**
    * @return Null, or the result of valueOf()
    */
    public static ${object.@name}Fields valueOfNullSafe(String value) {
        if (value != null) {
            return valueOf(value);
        }
        return null;
    }
}
